package cn.wolfcode.p2p.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import cn.wolfcode.base.QueryObject;
import cn.wolfcode.p2p.base.domain.SystemDictionary;
import cn.wolfcode.p2p.base.mapper.SystemDictionaryMapper;
import cn.wolfcode.p2p.base.service.ISystemDictionaryService;

@Service
@Transactional
public class SystemDictionaryServiceImpl implements ISystemDictionaryService {
    @Autowired
    private SystemDictionaryMapper systemDictionaryMapper;
	
	@Transactional(readOnly=true)
	public PageInfo<SystemDictionary> query(QueryObject qo) {
		PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
		List<SystemDictionary> list = systemDictionaryMapper.selectList(qo);
		return new PageInfo<SystemDictionary>(list);
	}

	@Override
	public void saveOrUpdate(SystemDictionary sd) {
		if (sd.getId() != null){
			systemDictionaryMapper.updateById(sd);
			return;
		}
		systemDictionaryMapper.insert(sd);
	}

	@Override
	public Object listAll() {
		return systemDictionaryMapper.selectAll();
	}
}
